<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	  <title>{$seo_title}</title>	
	  <meta name="author" content="YzmCMS内容管理系统">
	  <meta name="keywords" content="{$keywords}" />
	  <meta name="description" content="{$description}" />  
	  <link href="{STATIC_URL}css/yzm-common.css" rel="stylesheet" type="text/css" />
	  <link href="{STATIC_URL}css/yzm-style.css" rel="stylesheet" type="text/css" />
	  <link href="{STATIC_URL}css/yzm-form.css" rel="stylesheet" type="text/css" />
	  <script type="text/javascript" src="{STATIC_URL}js/jquery-1.8.2.min.js"></script>
	  <script type="text/javascript" src="{STATIC_URL}js/yzm-front.js"></script>
	  <script type="text/javascript" src="{STATIC_URL}plugin/layer/layer.js"></script>
  </head>
<body>
{m:include "index","header"}
	 <div class="yzm-content-box yzm-form-box">
 		<div class="yzm-title">
 			<h2>在线留言</h2>
 			<span class="yzm-title-right">
 				当前位置：<a href="{SITE_URL}">首页</a>&gt; 在线留言
 			</span>
 		</div>
	  <form action="{U('guestbook/index/init')}" method="post" onsubmit="return checkall(this)">
	    <table class='yzm-table'>
	        <tr>
	            <td class="yzm-table-title">留言主题<span class="red">*</span></td>
	            <td>
	                <input type="text" value="" name="title" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">联系人<span class="red">*</span></td>
	            <td>
	                <input type="text" value="" name="name" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">电话</td>
	            <td>
	                <input type="text" value="" name="phone" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">Email</td>
	            <td>
	                <input type="email" value="" name="email" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">QQ</td>
	            <td>
	                <input type="text" value="" name="qq" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">地址</td>
	            <td>
	                <input type="text" value="" name="address" class="yzm-input-text">
	            </td>
	        </tr>
	        <tr>
	            <td class="yzm-table-title">留言内容<span class="red">*</span></td>
	            <td><textarea name="bookmsg" class="yzm-textarea"></textarea></td>
	        </tr>
	        {if $site['words_code']}
	        <tr>
	            <td class="yzm-table-title">验证码<span class="red">*</span></td>
	            <td>
	            	<input name="code" type="text" class="yzm-input-text" style="width:100px;">
	            	<img src="{U('api/index/code')}" onclick="this.src=this.src+'?'" class="yzm-code" title="看不清？点击更换">
	            </td>
	        </tr>
	        {/if}
	        <tr>
	            <td></td>
	            <td><input type="submit" name="dosubmit" value="确认提交" class="yzm-submit"></td>
	        </tr>
	    </table>
		</form> 
	 </div>
 
	 <!--留言列表 开始-->
	 <div class="yzm-content-box yzm-book">
	 		<div class="yzm-title">
				<h2>留言列表</h2>
			</div>
			{m:guestbook page="page" limit="5"}
			{loop $data $v}
			   <div class="yzm-book-list">
				  <p class="yzm-book-head">
				  	<strong>作者</strong>：{$v[name]}，
				  	<strong>留言主题</strong>：{$v[title]}
				  	<span>[{date('Y-m-d H:i:s',$v['booktime'])}]</span>
				  </p>
				  <p class="yzm-book-content">
				  	<strong>内容</strong>：{$v[bookmsg]}</p>
					<!-- 管理员回复 start -->
					{loop $v['admin_reply'] $v}
						<p class="yzm-book-content"><strong style="color:#de4c1c">管理员回复</strong>：{nl2br($v['bookmsg'])}</p>
					{/loop}
					<!-- 管理员回复 end -->
			   </div>
			{/loop} 	
			{if empty($data)}<div class="yzm-book-list"><p>暂无留言!</p></div>{/if}
			<div id="page">{$pages}</div>	  
	 </div>
	  <!--留言列表 结束-->
	  
	 <script type="text/javascript">
		function checkall(obj){
			if(obj.title.value==""){
				layer.msg("留言主题不能为空！", {icon:2});
				return false;
			}
			if(obj.name.value==""){
				layer.msg("联系人不能为空！", {icon:2});
				return false;
			}
			if(obj.bookmsg.value==""){
				layer.msg("留言内容不能为空！", {icon:2});
				return false;
			}	
			layer.msg('正在发布留言，请稍后……', {icon:16, time:0, shade:0.3});
			$.ajax({
				type: "POST",
				url: "{U('guestbook/index/init')}", 
				data: $(obj).serialize(),
				dataType: "json", 
				success: function (msg) {
					if(msg.status == 1){
						layer.msg(msg.message, {icon:1}, function(){
							location.reload();
						});
					}else{
						$(".yzm-code").attr('src',$(".yzm-code").attr('src') + '?' + Math.random());
						layer.msg(msg.message, {icon:2});
					}
				}
			})		 
			return false;
		}
	</script>
{m:include "index","footer"}